package com.westos.userauth.dao.impl;

import com.westos.userauth.dao.PartyDao;
import com.westos.userauth.dao.mybatis.PartyDAO;
import com.westos.userauth.domain.Party;
import com.westos.userauth.domain.PartyAttribute;
import com.westos.userauth.domain.Person;
import com.westos.userauth.dto.PartySearchDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MybatisPartyDao implements PartyDao {

    //引入mybatis的实现
    @Autowired
    private PartyDAO partyDao;

    @Override
    public int updatePartyByStatus(Party party, String status) {
        return partyDao.updatePartyByStatus(party,status);
    }

    @Override
    public List<Party> queryAll(PartySearchDto partySearchDto) {
        return partyDao.queryAll(null);
    }

    @Override
    public Party queryPartyByPartyId(String partyId) {
        return partyDao.queryPartyByPartyId(partyId);
    }

    @Override
    public int deletePartyByPartyId(String partyId) {
        return partyDao.deletePartyByPartyId(partyId);
    }

    @Override
    public int updatePartyAttribute(PartyAttribute partyAttribute) {
        return partyDao.updatePartyAttribute(partyAttribute,partyAttribute.getPartyId());
    }

    @Override
    public int removePartyAttribute(PartyAttribute partyAttribute) {
        return partyDao.deletePartyAttribute(partyAttribute.getPartyId());
    }

    @Override
    public List<Party> lookupParty(PartySearchDto partySearchDto) {
        Party party = new Party();

        party.setPartyId(partySearchDto.getPartyId());
        party.setCreatedByUserLogin(partySearchDto.getCreatedByUserLogin());
        party.setCreatedDate(partySearchDto.getCreatedDate());
        party.setLastModifiedByUserLogin(partySearchDto.getLastModifiedByUserLogin());
        party.setLastModifiedDate(partySearchDto.getLastModifiedDate());

        return partyDao.lookupParty(party);
    }

    @Override
    public Party findPartiesById(String id) {
        return partyDao.findPartiesById(id);
    }


    @Override
    public int insertParty(Party party) {
        return partyDao.insertParty(party);
    }

    public PartyDAO getPartyDao() {
        return partyDao;
    }

    public void setPartyDao(PartyDAO partyDao) {
        this.partyDao = partyDao;
    }
}
